Description: This changes the Top Posters Portal box to reflect top posters in last X days which keeps the list more current. Otherwise the same people tend to stay on that list.
I've made this work with both Top Posters in Last 30 Days and Top Posters overall. Example of both in play
I've taken Josh's instructions and updated them on how to have BOTH on your forums.
Sorta my first foray off my own back...and it's a bit trickier to do with custom islands because of the way the system forces content creation on the customs. Hopefully this works for you
Is here anything like 'Top Poster of the Month' out there that could display the top poster of the month instead of a list. Or if I can get this working, can I edit it to do that?
So it's for sure above the bottom EOF; and under the initial EOF>>> ?
Got a blank page at first, then noticed that the island was built just not shown... - - - - $body = << EOF; - - - -
Note! Carte Blanches instructions might have an error as in the above text it was first called top_post_30.php, had to change to top_posters_30.php as that was my filename at least!
I got another issue with 7.2.2 and the verison from Carte Blanches, the style in the box screws up, if cut and paste as below the backgroun goes black and my default backgroun on all other boxes are white... if I leave more of the original code it end up being either double heading or leave a bit less and I get a box in a box (in both cases then with right styles though)...
There may be issues with my tweaks, as I said, it was my first foray into it, and actually, I've turned off the standard and custom islands showing posters.
I do recall I had to do some tweaking to get it to look just right, and stated, it was working in 7.1.1 but I didn't try it out with 7.2.2 and I have no idea how it'll play with 7.3
If I recall, I essentially took the original top posters embedded stuff, created the same thing and tweaked it according to Josh's or someone else's script and named it slight differently so that the original function still existed and my altered one could too. But, heck, that's been some time ago and my brain being all mushy at the moment....bleh.
You take sd's code and put it in place of the code in the /cache_builders/top_posters.php file. Upload it and edit the post islands language file if you want to change the title.
Also, the only problem I have with this is that this forces you to replace the top posters with top posters over the last x days.
As stated previously, I was getting too many people trying to push their epeens on post counts over the long haul that I disabled both of my islands showing top posters overall and top posters over last 30 days, but I think I may bring back just the X days variant because of it's dynamic non accruing nature. I'll see if I can't get it working again in a custom island instead of having it overwriting the original top posters one.
Btw, just as a matter of principles too, I've also disabled showing post counts on my forums because of the idiotic nature of some just trying to push post counts higher with "+1" etc.
$query = " SELECT COUNT(*) as total, p.USER_ID, u.USER_DISPLAY_NAME, u.USER_MEMBERSHIP_LEVEL, up.USER_NAME_COLOR FROM {$config['TABLE_PREFIX']}POSTS as p, {$config['TABLE_PREFIX']}USERS as u, {$config['TABLE_PREFIX']}USER_PROFILE as up
WHERE u.USER_ID = up.USER_ID AND p.POST_POSTED_TIME > $limittime AND p.USER_ID != 1 AND p.USER_ID = u.USER_ID GROUP BY p.USER_ID ORDER BY total DESC limit {$config['TOP_POSTERS']} "; $sth = $dbh->do_query($query); $users = array(); $i = 0; while(list($total,$uid,$username,$memberlevel,$namecolor) = $dbh->fetch_array($sth)) { $users[$i]['namecolor'] = $html->user_color($username, $namecolor, $memberlevel); $users[$i]['name'] = $username; $users[$i]['posts'] = $total; $users[$i]['uid'] = $uid; $i++; } // end while
/* DO NOT CHANGE THE LINE BELOW */ $body = <<<EOF <?php include("/your server path here/cache/top_post_30.php") ?>
EOF; /* DO NOT CHANGE THE LINE ABOVE */
What it does is when it fires based on the timings you've placed, it uses the "island_top_posters_30.tpl" file as a template to create some html code. it then saves this code in your cache directory as "top_post_30.php" or you can change this to be whatever you want as well. It also chmods it so it's usable, and then creates html content and just sucks in the contents of that file for display.
Thing to note is that you need to use your own server path rather than what I wrote near the bottom..i.e. replace "your server path here" with your server path.
I am by no means a fully proficient php coder, I'm more an engineer who can take existing things and make tweaks to get what I want out of them, so, if I've got "not so elegant" codign practices...this is why. Lord knows I couldn't sit down and yield this stuff from scratch.
If one of you more proficient coders notices any major issues, by all means feel free to post corrections...I'm all about function, not form and won't have feelings hurt
One final note, the # of people listed is pulled from the Portal Settings page, the # contained within the Top Posters field. I think it makes for a nice symmetry that if you're running both total top posters and top posters over X days that they have the same # of users listed.
Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.
Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.